package br.com.guidebar.models;

import android.widget.Adapter;

import java.util.NoSuchElementException;

public class Product {
    private Integer id;
    private Double price;
    private String name;
    private Integer quantity;
    private Integer availableQuantity;
    private String image;
    private String description;
    private Boolean isActive;
    private Event event = new Event();
    private Integer eventId;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Double getPrice() {
        return price;
    }

    public void setPrice(Double price) {
        this.price = price;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getQuantity() {
        return quantity;
    }

    public void setQuantity(Integer quantity) {
        this.quantity = quantity;
    }

    public String getImage() {
        return image;
    }

    public void setImage(String image) {
        this.image = image;
    }


    public Event getEvent() {
        return event;
    }

    public void setEvent(Event event) {
        this.event = event;
    }


    public static Integer getPositionById(final Adapter adapter,
                                          final Integer id) {
        Integer posicao = 0;
        try {
            final int count = adapter.getCount();
            for (int pos = 0; pos < count; pos++) {
                Product i = (Product) adapter.getItem(pos);

                if (id == (i.getId())) {
                    posicao = pos;
                }
            }
        } catch (NoSuchElementException erro) {
            erro.printStackTrace();
        }
        return posicao;
    }

    public Integer getAvailableQuantity() {
        return availableQuantity;
    }

    public void setAvailableQuantity(Integer availableQuantity) {
        this.availableQuantity = availableQuantity;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Boolean getIsActive() {
        return isActive;
    }

    public void setIsActive(Boolean isActive) {
        this.isActive = isActive;
    }

    public Integer getEventId() {
        return eventId;
    }

    public void setEventId(Integer eventId) {
        this.eventId = eventId;
    }

}
